module.exports = function injectLivereload(req, res, next) {
  const send = res.send;
  res.send = function (string) {
    const isHTML = typeof string === 'string' && string.includes('</html>');
    if (isHTML) {
      // 在 </body> 标签前注入 livereload 脚本
      // const livereloadScript = '<script src="http://localhost:35729/livereload.js"></script>';
      // string = string.replace('</body>', `${livereloadScript}\n</body>`);
    }
    send.call(this, string);
  };
  next();
};
